from django.utils.deprecation import MiddlewareMixin
from django.shortcuts import redirect

class AuthMiddleware(MiddlewareMixin):
    def process_request(self, request):
        if request.path_info in ["/login/", "/captcha/"]:
            return None
        info_dict = request.session.get('info')
        if info_dict:
            request.info = info_dict
        else:
            return redirect('/login/')
